#ifndef THINK_THINK_APP_H
#define THINK_THINK_APP_H

static char* think_app =
	"\n"
	"// +----------------------------------------------------------------------\n"
	"// | ThinkPHP [ WE CAN DO IT JUST THINK ]\n"
	"// +----------------------------------------------------------------------\n"
	"// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.\n"
	"// +----------------------------------------------------------------------\n"
	"// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )\n"
	"// +----------------------------------------------------------------------\n"
	"// | Author: liu21st <liu21st@gmail.com>\n"
	"// +----------------------------------------------------------------------\n"
	"\n"
	"namespace think;\n"
	"\n"
	"use think\\exception\\ClassNotFoundException;\n"
	"use think\\exception\\HttpException;\n"
	"use think\\exception\\HttpResponseException;\n"
	"use think\\exception\\RouteNotFoundException;\n"
	"\n"
	"/**\n"
	" * App 应用管理\n"
	" * @author liu21st <liu21st@gmail.com>\n"
	" */\n"
	"class App\n"
	"{\n"
	"    /**\n"
	"     * @var bool 是否初始化过\n"
	"     */\n"
	"    protected static $init = false;\n"
	"\n"
	"    /**\n"
	"     * @var string 当前模块路径\n"
	"     */\n"
	"    public static $modulePath;\n"
	"\n"
	"    /**\n"
	"     * @var bool 应用调试模式\n"
	"     */\n"
	"    public static $debug = true;\n"
	"\n"
	"    /**\n"
	"     * @var string 应用类库命名空间\n"
	"     */\n"
	"    public static $namespace = \'app\';\n"
	"\n"
	"    /**\n"
	"     * @var bool 应用类库后缀\n"
	"     */\n"
	"    public static $suffix = false;\n"
	"\n"
	"    /**\n"
	"     * @var bool 应用路由检测\n"
	"     */\n"
	"    protected static $routeCheck;\n"
	"\n"
	"    /**\n"
	"     * @var bool 严格路由检测\n"
	"     */\n"
	"    protected static $routeMust;\n"
	"\n"
	"    /**\n"
	"     * @var array 请求调度分发\n"
	"     */\n"
	"    protected static $dispatch;\n"
	"\n"
	"    /**\n"
	"     * @var array 额外加载文件\n"
	"     */\n"
	"    protected static $file = [];\n"
	"\n"
	"    /**\n"
	"     * 执行应用程序\n"
	"     * @access public\n"
	"     * @param  Request $request 请求对象\n"
	"     * @return Response\n"
	"     * @throws Exception\n"
	"     */\n"
	"    public static function run(Request $request = null)\n"
	"    {\n"
	"        $request = is_null($request) ? Request::instance() : $request;\n"
	"\n"
	"        try {\n"
	"            $config = self::initCommon();\n"
	"\n"
	"            // 模块/控制器绑定\n"
	"            if (defined(\'BIND_MODULE\')) {\n"
	"                BIND_MODULE && Route::bind(BIND_MODULE);\n"
	"            } elseif ($config[\'auto_bind_module\']) {\n"
	"                // 入口自动绑定\n"
	"                $name = pathinfo($request->baseFile(), PATHINFO_FILENAME);\n"
	"                if ($name && \'index\' != $name && is_dir(APP_PATH . $name)) {\n"
	"                    Route::bind($name);\n"
	"                }\n"
	"            }\n"
	"\n"
	"            $request->filter($config[\'default_filter\']);\n"
	"\n"
	"            // 默认语言\n"
	"            Lang::range($config[\'default_lang\']);\n"
	"            // 开启多语言机制 检测当前语言\n"
	"            $config[\'lang_switch_on\'] && Lang::detect();\n"
	"            $request->langset(Lang::range());\n"
	"\n"
	"            // 加载系统语言包\n"
	"            Lang::load([\n"
	"                THINK_PATH . \'lang\' . DS . $request->langset() . EXT,\n"
	"                APP_PATH . \'lang\' . DS . $request->langset() . EXT,\n"
	"            ]);\n"
	"\n"
	"            // 监听 app_dispatch\n"
	"            Hook::listen(\'app_dispatch\', self::$dispatch);\n"
	"            // 获取应用调度信息\n"
	"            $dispatch = self::$dispatch;\n"
	"\n"
	"            // 未设置调度信息则进行 URL 路由检测\n"
	"            if (empty($dispatch)) {\n"
	"                $dispatch = self::routeCheck($request, $config);\n"
	"            }\n"
	"\n"
	"            // 记录当前调度信息\n"
	"            $request->dispatch($dispatch);\n"
	"\n"
	"            // 记录路由和请求信息\n"
	"            if (self::$debug) {\n"
	"                Log::record(\'[ ROUTE ] \' . var_export($dispatch, true), \'info\');\n"
	"                Log::record(\'[ HEADER ] \' . var_export($request->header(), true), \'info\');\n"
	"                Log::record(\'[ PARAM ] \' . var_export($request->param(), true), \'info\');\n"
	"            }\n"
	"\n"
	"            // 监听 app_begin\n"
	"            Hook::listen(\'app_begin\', $dispatch);\n"
	"\n"
	"            // 请求缓存检查\n"
	"            $request->cache(\n"
	"                $config[\'request_cache\'],\n"
	"                $config[\'request_cache_expire\'],\n"
	"                $config[\'request_cache_except\']\n"
	"            );\n"
	"\n"
	"            $data = self::exec($dispatch, $config);\n"
	"        } catch (HttpResponseException $exception) {\n"
	"            $data = $exception->getResponse();\n"
	"        }\n"
	"\n"
	"        // 清空类的实例化\n"
	"        Loader::clearInstance();\n"
	"\n"
	"        // 输出数据到客户端\n"
	"        if ($data instanceof Response) {\n"
	"            $response = $data;\n"
	"        } elseif (!is_null($data)) {\n"
	"            // 默认自动识别响应输出类型\n"
	"            $type = $request->isAjax() ?\n"
	"            Config::get(\'default_ajax_return\') :\n"
	"            Config::get(\'default_return_type\');\n"
	"\n"
	"            $response = Response::create($data, $type);\n"
	"        } else {\n"
	"            $response = Response::create();\n"
	"        }\n"
	"\n"
	"        // 监听 app_end\n"
	"        Hook::listen(\'app_end\', $response);\n"
	"\n"
	"        return $response;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 初始化应用，并返回配置信息\n"
	"     * @access public\n"
	"     * @return array\n"
	"     */\n"
	"    public static function initCommon()\n"
	"    {\n"
	"        if (empty(self::$init)) {\n"
	"            if (defined(\'APP_NAMESPACE\')) {\n"
	"                self::$namespace = APP_NAMESPACE;\n"
	"            }\n"
	"\n"
	"            Loader::addNamespace(self::$namespace, APP_PATH);\n"
	"\n"
	"            // 初始化应用\n"
	"            $config       = self::init();\n"
	"            self::$suffix = $config[\'class_suffix\'];\n"
	"\n"
	"            // 应用调试模式\n"
	"            self::$debug = Env::get(\'app_debug\', Config::get(\'app_debug\'));\n"
	"\n"
	"            if (!self::$debug) {\n"
	"                ini_set(\'display_errors\', \'Off\');\n"
	"            } elseif (!IS_CLI) {\n"
	"                // 重新申请一块比较大的 buffer\n"
	"                if (ob_get_level() > 0) {\n"
	"                    $output = ob_get_clean();\n"
	"                }\n"
	"\n"
	"                ob_start();\n"
	"\n"
	"                if (!empty($output)) {\n"
	"                    echo $output;\n"
	"                }\n"
	"\n"
	"            }\n"
	"\n"
	"            if (!empty($config[\'root_namespace\'])) {\n"
	"                Loader::addNamespace($config[\'root_namespace\']);\n"
	"            }\n"
	"\n"
	"            // 加载额外文件\n"
	"            if (!empty($config[\'extra_file_list\'])) {\n"
	"                foreach ($config[\'extra_file_list\'] as $file) {\n"
	"                    $file = strpos($file, \'.\') ? $file : APP_PATH . $file . EXT;\n"
	"                    if (is_file($file) && !isset(self::$file[$file])) {\n"
	"                        include $file;\n"
	"                        self::$file[$file] = true;\n"
	"                    }\n"
	"                }\n"
	"            }\n"
	"\n"
	"            // 设置系统时区\n"
	"            date_default_timezone_set($config[\'default_timezone\']);\n"
	"\n"
	"            // 监听 app_init\n"
	"            Hook::listen(\'app_init\');\n"
	"\n"
	"            self::$init = true;\n"
	"        }\n"
	"\n"
	"        return Config::get();\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 初始化应用或模块\n"
	"     * @access public\n"
	"     * @param string $module 模块名\n"
	"     * @return array\n"
	"     */\n"
	"    private static function init($module = \'\')\n"
	"    {\n"
	"        // 定位模块目录\n"
	"        $module = $module ? $module . DS : \'\';\n"
	"\n"
	"        // 加载初始化文件\n"
	"        if (is_file(APP_PATH . $module . \'init\' . EXT)) {\n"
	"            include APP_PATH . $module . \'init\' . EXT;\n"
	"        } elseif (is_file(RUNTIME_PATH . $module . \'init\' . EXT)) {\n"
	"            include RUNTIME_PATH . $module . \'init\' . EXT;\n"
	"        } else {\n"
	"            // 加载模块配置\n"
	"            $config = Config::load(CONF_PATH . $module . \'config\' . CONF_EXT);\n"
	"\n"
	"            // 读取数据库配置文件\n"
	"            $filename = CONF_PATH . $module . \'database\' . CONF_EXT;\n"
	"            Config::load($filename, \'database\');\n"
	"\n"
	"            // 读取扩展配置文件\n"
	"            if (is_dir(CONF_PATH . $module . \'extra\')) {\n"
	"                $dir   = CONF_PATH . $module . \'extra\';\n"
	"                $files = scandir($dir);\n"
	"                foreach ($files as $file) {\n"
	"                    if (\'.\' . pathinfo($file, PATHINFO_EXTENSION) === CONF_EXT) {\n"
	"                        $filename = $dir . DS . $file;\n"
	"                        Config::load($filename, pathinfo($file, PATHINFO_FILENAME));\n"
	"                    }\n"
	"                }\n"
	"            }\n"
	"\n"
	"            // 加载应用状态配置\n"
	"            if ($config[\'app_status\']) {\n"
	"                Config::load(CONF_PATH . $module . $config[\'app_status\'] . CONF_EXT);\n"
	"            }\n"
	"\n"
	"            // 加载行为扩展文件\n"
	"            if (is_file(CONF_PATH . $module . \'tags\' . EXT)) {\n"
	"                Hook::import(include CONF_PATH . $module . \'tags\' . EXT);\n"
	"            }\n"
	"\n"
	"            // 加载公共文件\n"
	"            $path = APP_PATH . $module;\n"
	"            if (is_file($path . \'common\' . EXT)) {\n"
	"                include $path . \'common\' . EXT;\n"
	"            }\n"
	"\n"
	"            // 加载当前模块语言包\n"
	"            if ($module) {\n"
	"                Lang::load($path . \'lang\' . DS . Request::instance()->langset() . EXT);\n"
	"            }\n"
	"        }\n"
	"\n"
	"        return Config::get();\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置当前请求的调度信息\n"
	"     * @access public\n"
	"     * @param array|string  $dispatch 调度信息\n"
	"     * @param string        $type     调度类型\n"
	"     * @return void\n"
	"     */\n"
	"    public static function dispatch($dispatch, $type = \'module\')\n"
	"    {\n"
	"        self::$dispatch = [\'type\' => $type, $type => $dispatch];\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 执行函数或者闭包方法 支持参数调用\n"
	"     * @access public\n"
	"     * @param string|array|\\Closure $function 函数或者闭包\n"
	"     * @param array                 $vars     变量\n"
	"     * @return mixed\n"
	"     */\n"
	"    public static function invokeFunction($function, $vars = [])\n"
	"    {\n"
	"        $reflect = new \\ReflectionFunction($function);\n"
	"        $args    = self::bindParams($reflect, $vars);\n"
	"\n"
	"        // 记录执行信息\n"
	"        self::$debug && Log::record(\'[ RUN ] \' . $reflect->__toString(), \'info\');\n"
	"\n"
	"        return $reflect->invokeArgs($args);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 调用反射执行类的方法 支持参数绑定\n"
	"     * @access public\n"
	"     * @param string|array $method 方法\n"
	"     * @param array        $vars   变量\n"
	"     * @return mixed\n"
	"     */\n"
	"    public static function invokeMethod($method, $vars = [])\n"
	"    {\n"
	"        if (is_array($method)) {\n"
	"            $class   = is_object($method[0]) ? $method[0] : self::invokeClass($method[0]);\n"
	"            $reflect = new \\ReflectionMethod($class, $method[1]);\n"
	"        } else {\n"
	"            // 静态方法\n"
	"            $reflect = new \\ReflectionMethod($method);\n"
	"        }\n"
	"\n"
	"        $args = self::bindParams($reflect, $vars);\n"
	"\n"
	"        self::$debug && Log::record(\'[ RUN ] \' . $reflect->class . \'->\' . $reflect->name . \'[ \' . $reflect->getFileName() . \' ]\', \'info\');\n"
	"\n"
	"        return $reflect->invokeArgs(isset($class) ? $class : null, $args);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 调用反射执行类的实例化 支持依赖注入\n"
	"     * @access public\n"
	"     * @param string $class 类名\n"
	"     * @param array  $vars  变量\n"
	"     * @return mixed\n"
	"     */\n"
	"    public static function invokeClass($class, $vars = [])\n"
	"    {\n"
	"        $reflect     = new \\ReflectionClass($class);\n"
	"        $constructor = $reflect->getConstructor();\n"
	"        $args        = $constructor ? self::bindParams($constructor, $vars) : [];\n"
	"\n"
	"        return $reflect->newInstanceArgs($args);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 绑定参数\n"
	"     * @access private\n"
	"     * @param \\ReflectionMethod|\\ReflectionFunction $reflect 反射类\n"
	"     * @param array                                 $vars    变量\n"
	"     * @return array\n"
	"     */\n"
	"    private static function bindParams($reflect, $vars = [])\n"
	"    {\n"
	"        // 自动获取请求变量\n"
	"        if (empty($vars)) {\n"
	"            $vars = Config::get(\'url_param_type\') ?\n"
	"            Request::instance()->route() :\n"
	"            Request::instance()->param();\n"
	"        }\n"
	"\n"
	"        $args = [];\n"
	"        if ($reflect->getNumberOfParameters() > 0) {\n"
	"            // 判断数组类型 数字数组时按顺序绑定参数\n"
	"            reset($vars);\n"
	"            $type = key($vars) === 0 ? 1 : 0;\n"
	"\n"
	"            foreach ($reflect->getParameters() as $param) {\n"
	"                $args[] = self::getParamValue($param, $vars, $type);\n"
	"            }\n"
	"        }\n"
	"\n"
	"        return $args;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取参数值\n"
	"     * @access private\n"
	"     * @param \\ReflectionParameter  $param 参数\n"
	"     * @param array                 $vars  变量\n"
	"     * @param string                $type  类别\n"
	"     * @return array\n"
	"     */\n"
	"    private static function getParamValue($param, &$vars, $type)\n"
	"    {\n"
	"        $name  = $param->getName();\n"
	"        $class = $param->getClass();\n"
	"\n"
	"        if ($class) {\n"
	"            $className = $class->getName();\n"
	"            $bind      = Request::instance()->$name;\n"
	"\n"
	"            if ($bind instanceof $className) {\n"
	"                $result = $bind;\n"
	"            } else {\n"
	"                if (method_exists($className, \'invoke\')) {\n"
	"                    $method = new \\ReflectionMethod($className, \'invoke\');\n"
	"\n"
	"                    if ($method->isPublic() && $method->isStatic()) {\n"
	"                        return $className::invoke(Request::instance());\n"
	"                    }\n"
	"                }\n"
	"\n"
	"                $result = method_exists($className, \'instance\') ?\n"
	"                $className::instance() :\n"
	"                new $className;\n"
	"            }\n"
	"        } elseif (1 == $type && !empty($vars)) {\n"
	"            $result = array_shift($vars);\n"
	"        } elseif (0 == $type && isset($vars[$name])) {\n"
	"            $result = $vars[$name];\n"
	"        } elseif ($param->isDefaultValueAvailable()) {\n"
	"            $result = $param->getDefaultValue();\n"
	"        } else {\n"
	"            throw new \\InvalidArgumentException(\'method param miss:\' . $name);\n"
	"        }\n"
	"\n"
	"        return $result;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 执行调用分发\n"
	"     * @access protected\n"
	"     * @param array $dispatch 调用信息\n"
	"     * @param array $config   配置信息\n"
	"     * @return Response|mixed\n"
	"     * @throws \\InvalidArgumentException\n"
	"     */\n"
	"    protected static function exec($dispatch, $config)\n"
	"    {\n"
	"        switch ($dispatch[\'type\']) {\n"
	"            case \'redirect\': // 重定向跳转\n"
	"                $data = Response::create($dispatch[\'url\'], \'redirect\')\n"
	"                    ->code($dispatch[\'status\']);\n"
	"                break;\n"
	"            case \'module\': // 模块/控制器/操作\n"
	"                $data = self::module(\n"
	"                    $dispatch[\'module\'],\n"
	"                    $config,\n"
	"                    isset($dispatch[\'convert\']) ? $dispatch[\'convert\'] : null\n"
	"                );\n"
	"                break;\n"
	"            case \'controller\': // 执行控制器操作\n"
	"                $vars = array_merge(Request::instance()->param(), $dispatch[\'var\']);\n"
	"                $data = Loader::action(\n"
	"                    $dispatch[\'controller\'],\n"
	"                    $vars,\n"
	"                    $config[\'url_controller_layer\'],\n"
	"                    $config[\'controller_suffix\']\n"
	"                );\n"
	"                break;\n"
	"            case \'method\': // 回调方法\n"
	"                $vars = array_merge(Request::instance()->param(), $dispatch[\'var\']);\n"
	"                $data = self::invokeMethod($dispatch[\'method\'], $vars);\n"
	"                break;\n"
	"            case \'function\': // 闭包\n"
	"                $data = self::invokeFunction($dispatch[\'function\']);\n"
	"                break;\n"
	"            case \'response\': // Response 实例\n"
	"                $data = $dispatch[\'response\'];\n"
	"                break;\n"
	"            default:\n"
	"                throw new \\InvalidArgumentException(\'dispatch type not support\');\n"
	"        }\n"
	"\n"
	"        return $data;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 执行模块\n"
	"     * @access public\n"
	"     * @param array $result  模块/控制器/操作\n"
	"     * @param array $config  配置参数\n"
	"     * @param bool  $convert 是否自动转换控制器和操作名\n"
	"     * @return mixed\n"
	"     * @throws HttpException\n"
	"     */\n"
	"    public static function module($result, $config, $convert = null)\n"
	"    {\n"
	"        if (is_string($result)) {\n"
	"            $result = explode(\'/\', $result);\n"
	"        }\n"
	"\n"
	"        $request = Request::instance();\n"
	"\n"
	"        if ($config[\'app_multi_module\']) {\n"
	"            // 多模块部署\n"
	"            $module    = strip_tags(strtolower($result[0] ?: $config[\'default_module\']));\n"
	"            $bind      = Route::getBind(\'module\');\n"
	"            $available = false;\n"
	"\n"
	"            if ($bind) {\n"
	"                // 绑定模块\n"
	"                list($bindModule) = explode(\'/\', $bind);\n"
	"\n"
	"                if (empty($result[0])) {\n"
	"                    $module    = $bindModule;\n"
	"                    $available = true;\n"
	"                } elseif ($module == $bindModule) {\n"
	"                    $available = true;\n"
	"                }\n"
	"            } elseif (!in_array($module, $config[\'deny_module_list\']) && is_dir(APP_PATH . $module)) {\n"
	"                $available = true;\n"
	"            }\n"
	"\n"
	"            // 模块初始化\n"
	"            if ($module && $available) {\n"
	"                // 初始化模块\n"
	"                $request->module($module);\n"
	"                $config = self::init($module);\n"
	"\n"
	"                // 模块请求缓存检查\n"
	"                $request->cache(\n"
	"                    $config[\'request_cache\'],\n"
	"                    $config[\'request_cache_expire\'],\n"
	"                    $config[\'request_cache_except\']\n"
	"                );\n"
	"            } else {\n"
	"                throw new HttpException(404, \'module not exists:\' . $module);\n"
	"            }\n"
	"        } else {\n"
	"            // 单一模块部署\n"
	"            $module = \'\';\n"
	"            $request->module($module);\n"
	"        }\n"
	"\n"
	"        // 设置默认过滤机制\n"
	"        $request->filter($config[\'default_filter\']);\n"
	"\n"
	"        // 当前模块路径\n"
	"        App::$modulePath = APP_PATH . ($module ? $module . DS : \'\');\n"
	"\n"
	"        // 是否自动转换控制器和操作名\n"
	"        $convert = is_bool($convert) ? $convert : $config[\'url_convert\'];\n"
	"\n"
	"        // 获取控制器名\n"
	"        $controller = strip_tags($result[1] ?: $config[\'default_controller\']);\n"
	"\n"
	"        if (!preg_match(\'/^[A-Za-z](\\w|\\.)*$/\', $controller)) {\n"
	"            throw new HttpException(404, \'controller not exists:\' . $controller);\n"
	"        }\n"
	"\n"
	"        $controller = $convert ? strtolower($controller) : $controller;\n"
	"\n"
	"        // 获取操作名\n"
	"        $actionName = strip_tags($result[2] ?: $config[\'default_action\']);\n"
	"        if (!empty($config[\'action_convert\'])) {\n"
	"            $actionName = Loader::parseName($actionName, 1);\n"
	"        } else {\n"
	"            $actionName = $convert ? strtolower($actionName) : $actionName;\n"
	"        }\n"
	"\n"
	"        // 设置当前请求的控制器、操作\n"
	"        $request->controller(Loader::parseName($controller, 1))->action($actionName);\n"
	"\n"
	"        // 监听module_init\n"
	"        Hook::listen(\'module_init\', $request);\n"
	"\n"
	"        try {\n"
	"            $instance = Loader::controller(\n"
	"                $controller,\n"
	"                $config[\'url_controller_layer\'],\n"
	"                $config[\'controller_suffix\'],\n"
	"                $config[\'empty_controller\']\n"
	"            );\n"
	"        } catch (ClassNotFoundException $e) {\n"
	"            throw new HttpException(404, \'controller not exists:\' . $e->getClass());\n"
	"        }\n"
	"\n"
	"        // 获取当前操作名\n"
	"        $action = $actionName . $config[\'action_suffix\'];\n"
	"\n"
	"        $vars = [];\n"
	"        if (is_callable([$instance, $action])) {\n"
	"            // 执行操作方法\n"
	"            $call = [$instance, $action];\n"
	"            // 严格获取当前操作方法名\n"
	"            $reflect    = new \\ReflectionMethod($instance, $action);\n"
	"            $methodName = $reflect->getName();\n"
	"            $suffix     = $config[\'action_suffix\'];\n"
	"            $actionName = $suffix ? substr($methodName, 0, -strlen($suffix)) : $methodName;\n"
	"            $request->action($actionName);\n"
	"\n"
	"        } elseif (is_callable([$instance, \'_empty\'])) {\n"
	"            // 空操作\n"
	"            $call = [$instance, \'_empty\'];\n"
	"            $vars = [$actionName];\n"
	"        } else {\n"
	"            // 操作不存在\n"
	"            throw new HttpException(404, \'method not exists:\' . get_class($instance) . \'->\' . $action . \'()\');\n"
	"        }\n"
	"\n"
	"        Hook::listen(\'action_begin\', $call);\n"
	"\n"
	"        return self::invokeMethod($call, $vars);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * URL路由检测（根据PATH_INFO)\n"
	"     * @access public\n"
	"     * @param  \\think\\Request $request 请求实例\n"
	"     * @param  array          $config  配置信息\n"
	"     * @return array\n"
	"     * @throws \\think\\Exception\n"
	"     */\n"
	"    public static function routeCheck($request, array $config)\n"
	"    {\n"
	"        $path   = $request->path();\n"
	"        $depr   = $config[\'pathinfo_depr\'];\n"
	"        $result = false;\n"
	"\n"
	"        // 路由检测\n"
	"        $check = !is_null(self::$routeCheck) ? self::$routeCheck : $config[\'url_route_on\'];\n"
	"        if ($check) {\n"
	"            // 开启路由\n"
	"            if (is_file(RUNTIME_PATH . \'route.php\')) {\n"
	"                // 读取路由缓存\n"
	"                $rules = include RUNTIME_PATH . \'route.php\';\n"
	"                is_array($rules) && Route::rules($rules);\n"
	"            } else {\n"
	"                $files = $config[\'route_config_file\'];\n"
	"                foreach ($files as $file) {\n"
	"                    if (is_file(CONF_PATH . $file . CONF_EXT)) {\n"
	"                        // 导入路由配置\n"
	"                        $rules = include CONF_PATH . $file . CONF_EXT;\n"
	"                        is_array($rules) && Route::import($rules);\n"
	"                    }\n"
	"                }\n"
	"            }\n"
	"\n"
	"            // 路由检测（根据路由定义返回不同的URL调度）\n"
	"            $result = Route::check($request, $path, $depr, $config[\'url_domain_deploy\']);\n"
	"            $must   = !is_null(self::$routeMust) ? self::$routeMust : $config[\'url_route_must\'];\n"
	"\n"
	"            if ($must && false === $result) {\n"
	"                // 路由无效\n"
	"                throw new RouteNotFoundException();\n"
	"            }\n"
	"        }\n"
	"\n"
	"        // 路由无效 解析模块/控制器/操作/参数... 支持控制器自动搜索\n"
	"        if (false === $result) {\n"
	"            $result = Route::parseUrl($path, $depr, $config[\'controller_auto_search\']);\n"
	"        }\n"
	"\n"
	"        return $result;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置应用的路由检测机制\n"
	"     * @access public\n"
	"     * @param  bool $route 是否需要检测路由\n"
	"     * @param  bool $must  是否强制检测路由\n"
	"     * @return void\n"
	"     */\n"
	"    public static function route($route, $must = false)\n"
	"    {\n"
	"        self::$routeCheck = $route;\n"
	"        self::$routeMust  = $must;\n"
	"    }\n"
	"}\n"
	"\n"
;
#endif